package com.habdqn.studentmanager.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author Administrator 404状态处理 2017年5月25日
 * 
 */
@Controller
@RequestMapping("/errors")
public class ErrorsController {
    private static final Logger log = LoggerFactory.getLogger(ErrorsController.class);

    @RequestMapping("/404")
    public String notFound() {

        return "errors/404";
    }

    @RequestMapping("/500")
    public String systemError(HttpServletRequest request) {
        try {
            Throwable throwable = (Throwable) request.getAttribute("javax.servlet.error.exception");
            log.error("HTTP STATUS:500", throwable);
        }
        catch (Exception e) {
            log.error("no throws");
        }
        return "errors/500";
    }
}
